package com.lagou.controller;

import com.lagou.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 13771
 * @date 2021/1/15 17:29
 * @description
 */
@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/order/{stockId}")
    public String order(@PathVariable Integer stockId) {
        boolean flag = orderService.order(stockId);
        if (flag){
            return "下单成功！";
        }else {
            return "库存不足，下单失败！";
        }

    }

    @GetMapping("/pay/{orderId}")
    public String pay(@PathVariable Integer orderId) {
        return orderService.pay(orderId);
    }
}
